/**
 * Created by jt on 2017/5/8.
 */
import "./index.less";
// import "../../../unit/common/js/common/main_portal.js";

var projId = getArgs().id;

import setTableTpl from "./set_table.handlebars";
import {currTyp,dpstFlg,pubPriFlg} from "../config.js";

$.ajax({
    url: HOST_ADDR + '/cpmp/bidProjOffMngForPortal/viewProjRstDtl/'+projId,
    type: 'get',
    dataType: 'json',
    // headers: {
    //     'access_token': token,'login_type':'ums'
    // },
    contentType: "application/json",
    success: function(resp){
        if (!resp.success) {
            alert(resp.msgCod+' '+resp.msgInf);
            return;
        }
        console.log(resp);

        //处理数据
        resp.data.projNbrFmt = resp.data.projNbr || '';
        resp.data.bidOpenTimFmt = (new Date(resp.data.bidOpenTim)).Format("yyyy-MM-dd hh:mm:ss") || '';
        resp.data.bidEndTimFmt = (new Date(resp.data.bidEndTim)).Format("yyyy-MM-dd hh:mm:ss") || '';
        resp.data.currTypFmt = currTyp[resp.data.currTyp] || '';
        resp.data.dpstFlgFmt = dpstFlg[resp.data.dpstFlg] || '';
        resp.data.pubPriFlgFmt = pubPriFlg[resp.data.pubPriFlg] || '';

        if(resp.data.matTypDesc!=null && resp.data.matTypDesc!=''){
            resp.data.matTyp = resp.data.matTypDesc;
        }
        jQuery.ajax({
            url: HOST_ADDR + '/cpmp/bidProjOffMngForPortal/viewProjDtl/' + projId,
            type: 'get',
            dataType: 'json',
            contentType: "application/json",
            success: function (resp1) {
                if (!resp1.success) {
                    alert(resp1.msgCod + ' ' + resp1.msgInf);
                    return;
                }
                if(resp1.data.matTypDesc!=null && resp1.data.matTypDesc!=''){
                    resp.data.matTyp = resp1.data.matTypDesc;
                }

                let tableHtml = setTableTpl(resp.data);
                jQuery('.basicInfo').html(tableHtml);
                jQuery('.bidBok').html(resp.data.bidBok);
                jQuery('.setInfo').append(resp.data.rplMemo);
            },
            error: function (err) {
                console.log(err);
            }
        });

    },
    error:function(err){
        console.log(err);
    }
});
